Allow notification of betas to be independent of notifications of real upgrades.
authorrobertl <robertl>
Sun, 11 Apr 2010 18:11:46 +0000 (18:11 +0000)
committerrobertl <robertl>
Sun, 11 Apr 2010 18:11:46 +0000 (18:11 +0000)
gui/babeldata.h
gui/mainwindow.cpp
gui/mainwindow.h
gui/upgrade.cpp
gui/upgrade.h

index 5f87fb5a47fc74cd937c061a3a9db90ebe4d4471..2bf8c6eb8c130e4adeb132fc7710cf7ca587203b 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: babeldata.h,v 1.5 2010/02/15 02:57:00 robertl Exp $
+// $Id: babeldata.h,v 1.6 2010/04/11 18:11:46 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -58,7 +58,8 @@ public:
     upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))),
     installationUuid(QUuid::createUuid().toString()),
     startupVersionCheck(true),
-    reportStatistics(true)
+    reportStatistics(true),
+    allowBetaUpgrades(false)
   {
   };
   
@@ -105,6 +106,7 @@ public:
     // Global preferences.
     sg.addVarSetting(new BoolSetting("app.startupVersionCheck", startupVersionCheck));
     sg.addVarSetting(new BoolSetting("app.reportStatistics", reportStatistics));
+    sg.addVarSetting(new BoolSetting("app.allowBetaUpgrades", allowBetaUpgrades));
 
   }
 
@@ -145,6 +147,7 @@ public:
   // Global preferences.
   bool startupVersionCheck;
   bool reportStatistics;
+  bool allowBetaUpgrades;
 
 };
 
index 7569d71f92a1f0b4396646c21e22bb8e3398d49b..6ab54e4a359daf655c52476f96d2af82f7ab0bc4 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: mainwindow.cpp,v 1.17 2010/02/16 02:49:43 robertl Exp $
+// $Id: mainwindow.cpp,v 1.18 2010/04/11 18:11:47 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -45,7 +45,7 @@ const int BabelData::noType = -1;
 const int BabelData::fileType = 0;
 const int BabelData::deviceType = 1;
 //------------------------------------------------------------------------
-static QString findBabelVersion()
+QString MainWindow::findBabelVersion()
 {
   QProcess babel;
   babel.start("gpsbabel", QStringList() << "-V");
@@ -56,10 +56,22 @@ static QString findBabelVersion()
     return QString();
 
   QString str = babel.readAll();
+  is_beta = str.contains("-beta");
   str.replace(QRegExp("^[\\s]*"),  "");
   str.replace(QRegExp("[\\s]+$"),  "");
   return str;
 }
+
+//------------------------------------------------------------------------
+// Decides whether available beta upgrades are suggested to user for download.
+bool MainWindow::allowBetaUpgrades()
+{
+  // If this is a beta version (which means the user consciously downloaded
+  // it and decided to be on the beta track or the user has ticked the 
+  // 'suggest beta upgrade' box, allow betas to be suggested for installation.
+  return is_beta || bd.allowBetaUpgrades;
+}
+
 //------------------------------------------------------------------------
 static QStringList getCharSets()
 {
@@ -177,7 +189,7 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent)
   if (bd.startupVersionCheck) {
     upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, 
                              bd.upgradeCheckTime, bd.installationUuid,
-                             bd.reportStatistics);
+                             bd.reportStatistics, allowBetaUpgrades());
   }
 }
 
@@ -966,8 +978,9 @@ void MainWindow::aboutActionX()
 void MainWindow::upgradeCheckActionX()
 {
     upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, 
-                             QDateTime(), bd.installationUuid,
-                             bd.reportStatistics);
+                             QDateTime(QDate(2000, 1, 1), QTime(0, 0)), 
+                             bd.installationUuid,
+                             bd.reportStatistics, allowBetaUpgrades());
 }
 
 //------------------------------------------------------------------------
index d8c0b02103caa2916ec52d6df3fd1b9ba1ff4792..017519e414454c20b61b52eab55c3760f4eaf71c 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: mainwindow.h,v 1.9 2010/02/16 02:49:43 robertl Exp $
+// $Id: mainwindow.h,v 1.10 2010/04/11 18:11:47 robertl Exp $
 //------------------------------------------------------------------------
 //
 //  Copyright (C) 2009  S. Khai Mong <khai@mangrai.com>.
@@ -40,6 +40,7 @@ private:
   Ui_MainWindow     ui;
   QList<Format>  formatList;
   QString        babelVersion;
+  bool          is_beta;
   QPixmap        lights[4];
   QStringList    charSets;
   AllFiltersData filterData;
@@ -50,6 +51,7 @@ private:
   void loadFormats();
   QString filterForFormat(int idx);
   QString ensureExtensionPresent(const QString &nanme, int idx);
+  QString findBabelVersion();
   bool    filterForFormatIncludes(int idx, const QString &s);
   int  formatIndexFromName(bool isFile, const QString &);
   QList<int>inputFileFormatIndices();
@@ -81,6 +83,7 @@ private:
   void setWidgetValues();
   void getWidgetValues();
   UpgradeCheck *upgrade;
+  bool allowBetaUpgrades();
   void osLoadDeviceNameCombos(QComboBox*);
 
 protected:
index c3b04f200a7328b2c2c0e0a3cb2f9153ec4b3e78..ca339aac9d714a5597dbed78d63eb0786bc40505 100644 (file)
@@ -1,5 +1,5 @@
 // -*- C++ -*-
-// $Id: upgrade.cpp,v 1.23 2010/02/23 15:38:26 robertl Exp $
+// $Id: upgrade.cpp,v 1.24 2010/04/11 18:11:47 robertl Exp $
 /*
     Copyright (C) 2009, 2010  Robert Lipe, robertlipe@gpsbabel.org
 
@@ -117,7 +117,8 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString &currentV
                int checkMethod,
                const QDateTime &lastCheckTime,
                const QString &installationUuid,
-               bool reportStatistics)
+               bool reportStatistics,
+               bool allowBeta)
 {
   currentVersion = currentVersionIn;
   currentVersion.remove("GPSBabel Version ");
@@ -154,8 +155,9 @@ UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString &currentV
     args += "&cpu=" + QString(utsname.machine);
   }
 #endif
+
   args += "&os_ver=" + getOsVersion();
-  args += "&beta_ok=1";   // Eventually to come from prefs.
+  args += QString("&beta_ok=%1").arg(allowBeta); 
   args += "&lang=" + QLocale::languageToString(locale.language());
   args += "&last_checkin=" + lastCheckTime.toString(Qt::ISODate);
 
index 32623317d12f597ac988ba110a8e0632339b7764..880380b3fd880140a5a677e0db04e5db695aa914 100644 (file)
@@ -44,7 +44,8 @@ public:
                                             int upgradeCheckMethod,
                                             const QDateTime &lastCheckTime,
                                             const QString &installationUuid,
-                                             bool reportStatistics
+                                             bool reportStatistics,
+                                             bool allowBeta
                                              );
   QDateTime getUpgradeWarningTime() {
     return upgradeWarningTime;